<include file="common:header"/>

<div id="header">
    <div class="header">
        <h1 class="tit">订单列表</h1>
    </div>
</div>
<ul class="state">
    <li><a href="{:U('Order/index')}" <if condition="$_GET['state'] eq ''">style="color:#67dca9;"</if>>全部</a></li>
    <li><a href="{:U('Order/index', array('state'=>'npay'))}" <if condition="$_GET['state'] eq 'npay'">style="color:#67dca9;"</if>>待付款</a></li>
    <li><a href="{:U('Order/index', array('state'=>'to_d'))}" <if condition="$_GET['state'] eq 'to_d'">style="color:#67dca9;"</if>>待发货</a></li>
    <li><a href="{:U('Order/index', array('state'=>'is_d'))}" <if condition="$_GET['state'] eq 'is_d'">style="color:#67dca9;"</if>>待收货</a></li>
    <eq name="Think.session.is_agent" value="1">
    <li><a href="{:U('Order/index', array('state'=>'ncheck'))}" <if condition="$_GET['state'] eq 'ncheck'">style="color:#67dca9;"</if>>审核</a></li>
    </eq>
</ul>
<div class="search">
    <form action="" type="get">
        <input type="hidden" name="m" value="Home">
        <input type="hidden" name="c" value="Order">
        <input type="hidden" name="a" value="index">
        <input type="hidden" name="state" value="{$state}" id="state">
        <input type="text" placeholder="订单号搜索.." name="search" id="search" value="{$search}"/>
        <button type="submit"></button>
    </form>
</div>

<notempty name="order">
    <div class="order-content">
        <volist name="order" id="vo">
            <div class="order-list">
                <p class="order-number">
                    订单号：<span>{$vo.order_id}{$vo['state']}</span>
                    <if condition="$vo['status'] eq 2">
                        <label class="fright">交易失败</label>
                    </if>
                    <if condition="$vo['is_deliver'] eq 1 AND $vo['status'] eq 0">
                        <label class="fright">待收货</label>
                        <elseif condition="$vo['status'] eq 3"/>
                        <label class="fright">交易成功</label>
                        <elseif condition="$vo['is_pay'] neq 1 AND $vo['status'] eq 0"/>
                        <label class="fright">待付款</label>
                        <elseif condition="$vo['is_pay'] eq 1 AND $vo['is_deliver'] neq 1 AND $vo['status'] eq 0 "/>
                        <label class="fright">待发货</label>
                        <if condition="$vo['state'] eq '0' AND $vo['status'] neq -1">
                            <label class="fright" style="color:orange;margin-right:0.05rem;">待审</label>
                        </if>
                        <elseif condition="$vo['status'] eq -1"/>
                        <label class="fright">已取消</label>
                    </if>
                </p>

                <volist name="vo['order_good']" id="v1">
                    <dl>
                        <a href="{:U('Order/order_confirm', array('id'=>$vo['id']))}">
                            <dt><img src="{$v1.img}"/></dt>
                            <dd>
                                <p class="order-name">{$v1.g_name}</p>
                                <p class="order-num"><span class="order-num-name">{$v1.spec_str}</span> <span>{$v1.num}</span><span>X</span></p>
                                <if condition="$v1.order_status eq 1"><span class="back_money">退款中</span></if>
                                <if condition="$v1.order_status eq 2"><span class="back_money">退款成功</span></if>
                                <if condition="$v1.order_status eq 3"><span class="back_money">退款失败</span></if>
                            </dd>
                        </a>
                    </dl>
                </volist>
                <p class="order-cash">共<span class="num">{$vo['good_num']}</span>件商品 合计：¥
                    <span class="cash">
                        <eq name="Think.session.user_id" value="$vo['uid']">
                            <!--订单表的price字段下单人的订单总额,包含运费,不包含折扣-->
                            <php>echo ($vo['price']*100 - $vo['discount']*100)/100;</php>
                            <else/>
                            <!--total_price字段上级代理的订单总额,不包含运费和折扣-->
                            <php>echo ($vo['total_price']*100 - $vo['discount']*100 + $vo['freight_price']*100)/100;</php>
                        </eq>
                        (含运费折扣)
                    </span>
                </p>
            </div>
        </volist>
    </div>
    <else />
    <div class="order-content" style="background-color: #fff;border-bottom:0;">
        <div class="no_data">
            <img src="{:C('__STATIC__')}{$theme}/Static/img/no_data.png" class="tip_img"/>
            <p class="tip_txt">暂时没有相关信息</p>
        </div>
    </div>
</notempty >
<div class="dropload-load" id="loading" style="display: none;"><span class="loading"></span>加载中...</div>
<link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/order_list.css"/>
<include file="common:footer"/>
<script type="text/javascript">
    //滚动加载更多
    var before_request = 1; // 上一次请求是否已经有返回来, 有才可以进行下一次请求
    var page = 1;
    function ajax_sourch_submit(){
        if(before_request == 0)// 上一次请求没回来 不进行下一次请求
            return false;
        before_request = 0;
        page ++;
        var search = $('#search').val();
        $.ajax({
            type : "post",
            url:"{:U('Order/more')}",
            data: {
                params : "{$params}",
                page: page,
                state: $('#state').val(),
                search: search
            },
            success: function(data)
            {
                $('#loading').show();
                if (data != 1) {
                    $('.order-content').append(data);
                    before_request = 1;
                } else {
                    $('#loading').text('没有更多的数据！');
                }
            }
        });
    }
</script>
